<%@ page import="com.portico.dept.solarch.Project" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="layout" content="main"/>
    <g:set var="entityName" value="${message(code: 'project.label', default: 'Project')}"/>
    <title><g:message code="default.edit.label" args="[entityName]"/></title>
</head>

<body>
%{--<div class="nav">--}%
%{--<span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>--}%
%{--<span class="menuButton"><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" /></g:link></span>--}%
%{--<span class="menuButton"><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></span>--}%
%{--</div>--}%
<div class="body">
%{--<h1><g:message code="default.edit.label" args="[entityName]" /></h1>--}%
<g:if test="${flash.message}">
    <div class="message">${flash.message}</div>
</g:if>
<g:hasErrors bean="${projectInstance}">
    <div class="errors">
        <g:renderErrors bean="${projectInstance}" as="list"/>
    </div>
</g:hasErrors>
<g:form method="post">
<g:hiddenField name="id" value="${projectInstance?.id}"/>
<g:hiddenField name="version" value="${projectInstance?.version}"/>
<div class="dialog">
<table>
<tbody>

<tr class="prop">
    <td valign="top" class="name">
        <label for="name"><g:message code="project.name.label" default="Name"/></label>
    </td>
    <td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'name', 'errors')}">
        <g:textField name="name" maxlength="200" value="${projectInstance?.name}"/>
    </td>
</tr>

<tr class="prop">
    <td valign="top" class="name">
        <label for="description"><g:message code="project.description.label" default="Description"/></label>
    </td>
    <td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'description', 'errors')}">
        <g:textArea name="description" cols="40" rows="5" value="${projectInstance?.description}"/>
    </td>
</tr>

<tr class="prop">
    <td valign="top" class="name">
        <label for="projectType"><g:message code="project.projectType.label" default="Project Type"/></label>
    </td>
    <td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'projectType', 'errors')}">
        <g:select name="projectType" from="${projectInstance.constraints.projectType.inList}"
                  value="${projectInstance?.projectType}" valueMessagePrefix="project.projectType"/>
    </td>
</tr>

<tr class="prop">
    <td valign="top" class="name">
        <label for="projectSubType"><g:message code="project.projectSubType.label" default="Project Sub Type"/></label>
    </td>
    <td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'projectSubType', 'errors')}">
        <g:select name="projectSubType" from="${projectInstance.constraints.projectSubType.inList}"
                  value="${projectInstance?.projectSubType}" valueMessagePrefix="project.projectSubType"/>
    </td>
</tr>

<tr class="prop">
    <td valign="top" class="name">
        <label for="projectState"><g:message code="project.projectState.label" default="Project State"/></label>
    </td>
    <td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'projectState', 'errors')}">
        <g:select name="projectState" from="${projectInstance.constraints.projectState.inList}"
                  value="${projectInstance?.projectState}" valueMessagePrefix="project.projectState"/>
    </td>
</tr>

<tr class="prop">
    <td valign="top" class="name">
        <label for="startDate"><g:message code="project.startDate.label" default="Start Date"/></label>
    </td>
    <td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'startDate', 'errors')}">
        <g:datePicker name="startDate" precision="day" value="${projectInstance?.startDate}"/>
    </td>
</tr>

<tr class="prop">
    <td valign="top" class="name">
        <label for="endDate"><g:message code="project.endDate.label" default="End Date"/></label>
    </td>
    <td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'endDate', 'errors')}">
        <g:datePicker name="endDate" precision="day" value="${projectInstance?.endDate}"/>
    </td>
</tr>

<tr class="prop">
    <td valign="top" class="name">
        <label for="sharePointUrl"><g:message code="project.sharePointUrl.label" default="Share Point Url"/></label>
    </td>
    <td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'sharePointUrl', 'errors')}">
        <g:textField name="sharePointUrl" value="${projectInstance?.sharePointUrl}"/>
    </td>
</tr>

<tr class="prop">
    <td valign="top" class="name">
        <label for="wikiUrl"><g:message code="project.wikiUrl.label" default="Wiki Url"/></label>
    </td>
    <td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'wikiUrl', 'errors')}">
        <g:textField name="wikiUrl" value="${projectInstance?.wikiUrl}"/>
    </td>
</tr>

<tr class="prop">
    <td valign="top" class="name">
        <label for="showProjectDashboard"><g:message code="project.showProjectDashboard.label"
                                                     default="Show Project Dashboard"/></label>
    </td>
    <td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'showProjectDashboard', 'errors')}">
        <g:checkBox name="showProjectDashboard" value="${projectInstance?.showProjectDashboard}"/>
    </td>
</tr>

%{--<tr class="prop">--}%
%{--<td valign="top" class="name">--}%
%{--<label for="forecast"><g:message code="project.forecast.label" default="Forecast" /></label>--}%
%{--</td>--}%
%{--<td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'forecast', 'errors')}">--}%
%{----}%
%{--<ul>--}%
%{--<g:each in="${projectInstance?.forecast?}" var="f">--}%
%{--<li><g:link controller="projectForecast" action="show" id="${f.id}">${f?.encodeAsHTML()}</g:link></li>--}%
%{--</g:each>--}%
%{--</ul>--}%
%{--<g:link controller="projectForecast" action="create" params="['project.id': projectInstance?.id]">${message(code: 'default.add.label', args: [message(code: 'projectForecast.label', default: 'ProjectForecast')])}</g:link>--}%

%{--</td>--}%
%{--</tr>--}%

<sec:ifAnyGranted roles="ROLE_SUPER_USER, ROLE_ADMIN_USER">

    <tr class="prop">
        <td valign="top" class="name">
            <label for="projectAdmins"><g:message code="project.projectAdmins.label" default="Project Admins"/></label>
        </td>
        <td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'projectAdmins', 'errors')}">
            <g:select name="projectAdmins" from="${com.portico.security.User.list()}" multiple="yes" optionKey="id"
                      size="5" value="${projectInstance?.projectAdmins*.id}"/>
        </td>
    </tr></sec:ifAnyGranted>

<tr class="prop">
    <td valign="top" class="name">
        <label for="projectNumber"><g:message code="project.projectNumber.label" default="PMO Project Number"/></label>
    </td>
    <td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'projectNumber', 'errors')}">
        <g:textField name="projectNumber" value="${projectInstance?.projectNumber}"/>
    </td>
</tr>

%{--<tr class="prop">--}%
%{--<td valign="top" class="name">--}%
%{--<label for="qualityDetails"><g:message code="project.qualityDetails.label" default="Quality Details" /></label>--}%
%{--</td>--}%
%{--<td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'qualityDetails', 'errors')}">--}%
%{----}%
%{--<ul>--}%
%{--<g:each in="${projectInstance?.qualityDetails?}" var="q">--}%
%{--<li><g:link controller="projectQuality" action="show" id="${q.id}">${q?.encodeAsHTML()}</g:link></li>--}%
%{--</g:each>--}%
%{--</ul>--}%
%{--<g:link controller="projectQuality" action="create" params="['project.id': projectInstance?.id]">${message(code: 'default.add.label', args: [message(code: 'projectQuality.label', default: 'ProjectQuality')])}</g:link>--}%

%{--</td>--}%
%{--</tr>--}%

%{--<tr class="prop">--}%
%{--<td valign="top" class="name">--}%
%{--<label for="recurringStatus"><g:message code="project.recurringStatus.label" default="Recurring Status" /></label>--}%
%{--</td>--}%
%{--<td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'recurringStatus', 'errors')}">--}%
%{----}%
%{--<ul>--}%
%{--<g:each in="${projectInstance?.recurringStatus?}" var="r">--}%
%{--<li><g:link controller="projectStatus" action="show" id="${r.id}">${r?.encodeAsHTML()}</g:link></li>--}%
%{--</g:each>--}%
%{--</ul>--}%
%{--<g:link controller="projectStatus" action="create" params="['project.id': projectInstance?.id]">${message(code: 'default.add.label', args: [message(code: 'projectStatus.label', default: 'ProjectStatus')])}</g:link>--}%

%{--</td>--}%
%{--</tr>--}%

%{--<tr class="prop">--}%
%{--<td valign="top" class="name">--}%
%{--<label for="releaseDetails"><g:message code="project.releaseDetails.label" default="Release Details" /></label>--}%
%{--</td>--}%
%{--<td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'releaseDetails', 'errors')}">--}%
%{----}%
%{--<ul>--}%
%{--<g:each in="${projectInstance?.releaseDetails?}" var="r">--}%
%{--<li><g:link controller="releaseDetail" action="show" id="${r.id}">${r?.encodeAsHTML()}</g:link></li>--}%
%{--</g:each>--}%
%{--</ul>--}%
%{--<g:link controller="releaseDetail" action="create" params="['project.id': projectInstance?.id]">${message(code: 'default.add.label', args: [message(code: 'releaseDetail.label', default: 'ReleaseDetail')])}</g:link>--}%

%{--</td>--}%
%{--</tr>--}%

%{--<tr class="prop">--}%
%{--<td valign="top" class="name">--}%
%{--<label for="risks"><g:message code="project.risks.label" default="Risks" /></label>--}%
%{--</td>--}%
%{--<td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'risks', 'errors')}">--}%
%{----}%
%{--<ul>--}%
%{--<g:each in="${projectInstance?.risks?}" var="r">--}%
%{--<li><g:link controller="projectRisks" action="show" id="${r.id}">${r?.encodeAsHTML()}</g:link></li>--}%
%{--</g:each>--}%
%{--</ul>--}%
%{--<g:link controller="projectRisks" action="create" params="['project.id': projectInstance?.id]">${message(code: 'default.add.label', args: [message(code: 'projectRisks.label', default: 'ProjectRisks')])}</g:link>--}%

%{--</td>--}%
%{--</tr>--}%

%{--<tr class="prop">--}%
%{--<td valign="top" class="name">--}%
%{--<label for="roster"><g:message code="project.roster.label" default="Roster" /></label>--}%
%{--</td>--}%
%{--<td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'roster', 'errors')}">--}%
%{----}%
%{--<ul>--}%
%{--<g:each in="${projectInstance?.roster?}" var="r">--}%
%{--<li><g:link controller="projectTeamMember" action="show" id="${r.id}">${r?.encodeAsHTML()}</g:link></li>--}%
%{--</g:each>--}%
%{--</ul>--}%
%{--<g:link controller="projectTeamMember" action="create" params="['project.id': projectInstance?.id]">${message(code: 'default.add.label', args: [message(code: 'projectTeamMember.label', default: 'ProjectTeamMember')])}</g:link>--}%

%{--</td>--}%
%{--</tr>--}%

<tr class="prop">
    <td valign="top" class="name">
        <label for="sponsor"><g:message code="project.sponsor.label" default="Sponsor"/></label>
    </td>
    <td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'sponsor', 'errors')}">
        <g:textField name="sponsor" value="${projectInstance?.sponsor}"/>
    </td>
</tr>

<tr class="prop">
    <td valign="top" class="name">
        <label for="technicalManager"><g:message code="project.technicalManager.label"
                                                 default="Technical Manager"/></label>
    </td>
    <td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'technicalManager', 'errors')}">
        <g:textField name="technicalManager" value="${projectInstance?.technicalManager}"/>
    </td>
</tr>

</tbody>
</table>
</div>

<div class="buttons">
    <span class="button"><g:actionSubmit class="save" action="update"
                                         value="${message(code: 'default.button.update.label', default: 'Update')}"/></span>
    <sec:ifAnyGranted roles="ROLE_SUPER_USER, ROLE_ADMIN_USER">
        <span class="button"><g:actionSubmit class="delete" action="delete"
                                             value="${message(code: 'default.button.delete.label', default: 'Delete')}"
                                             onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');"/></span>
    </sec:ifAnyGranted>
</div>
</g:form>
</div>
</body>
</html>
